<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Unit test for base code</title>
<script type="text/javascript" src="../lib/jsunit/app/jsUnitCore.js"></script>
<script type="text/javascript" src="../lib/prototype.js"></script>
<script type="text/javascript" src="../src/base.js"></script>
</head>
<body>
<script type="text/javascript">
	var base;
	
	function setUpPage() {
		base = new Antiquity.EventDriven();
		setUpPageStatus = "complete";
	}
	function testBaseObserve() {
		var handler = function(p) {
			p.count++;
			assertEquals("Parameters should be sent sucessfully. a=1", p.a, 1);
			assertEquals("Parameters should be sent sucessfully. b=2", p.b, 2);
			assertEquals("Parameters should be sent sucessfully. c=undefined", p.c, JSUNIT_UNDEFINED_VALUE);
		};
		base.observe("init", handler);
		assertNotNull("There should be totally 1 event queue now, whose name is 'init'.", base.events.init);
		assertEquals("There should be 1 handler in event 'init'.", base.events.init.length, 1);
		base.observe("init", handler);
		assertEquals("There should be 1 handler in event 'init'.", base.events.init.length, 2);
		base.observe("loading", handler);
		assertNotNull("There should be totally 1 event queue now, whose name is 'loading'.", base.events.loading);
		assertEquals("There should be 1 handler in event 'init'.", base.events.loading.length, 1);
	}
	function testBaseFire() {
		var params = {
			count: 0,
			a: 1,
			b: 2
		};
		base._fire("init", [params]);
		base._fire("loading", [params]);
		assertEquals("As long as handler is called, counter should equal to 3 now.", params.count, 3);
	}
</script>
</body>
</html>